package com.liuqianfei.markme.rules.core;

import com.liuqianfei.markme.core.Token;
import com.liuqianfei.markme.rules.AbstractState;
import com.liuqianfei.markme.rules.IAction;

import java.util.ArrayList;

/**
 * @author liuqianfei
 */
public class BlockAction implements IAction
{
    @Override
    public boolean parse(AbstractState state, boolean silent, int startLine, int endLine)
    {
        Token token;

        if (state.isInlineMode())
        {
            token          = new Token("inline", "", 0);
            token.content  = state.getSrc();
            token.map      = new int[]{0, 1};
            token.children = new ArrayList<>();
            state.getTokens().add(token);
        }
        else
        {
            state.getMd().parserBlock.parse(state.getSrc(), state.getMd(), state.getEnv(), state.getTokens());
        }

        // FIXME I add it
        return true;
    }
}
